home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part1 / 1897 < prev    next >
Encoding:
Text File  |  1996-08-06  |  1.0 KB  |  26 lines

  1. Newsgroups: comp.lang.c++
  2. Path: in1.uu.net!allegra!alice!ark
  3. From: ark@research.att.com (Andrew Koenig)
  4. Subject: Re: Destructors in functions
  5. Message-ID: <DL57qo.ICn@research.att.com>
  6. Organization: AT&T Bell Laboratories, Murray Hill NJ
  7. References: <4d7r65$dv9@newsbf02.news.aol.com>
  8. Date: Sat, 13 Jan 1996 23:25:35 GMT
  9.  
  10. In article <4d7r65$dv9@newsbf02.news.aol.com> weatby@aol.com (Weatby) writes:
  11.  
  12. > If you pass an object to a function, the language makes a bitwise copy of
  13. > it, local to the function.  (Assuming no copy constructor is defined.) 
  14. > Then, on the way out, the function calls the user-defined constructor.
  15.  
  16. Not quite true.  If you don't define a copy constructor, copying an
  17. object of that class is equivalent to copying its elements (which may
  18. have their own copy constructors).
  19.  
  20. If your class has a non-empty destructor, it should have an explicit
  21. copy constructor and assignment operator.  It is possible to imagine
  22. exceptions to that rule, but they are rare.
  23. -- 
  24.                 --Andrew Koenig
  25.                   ark@research.att.com
  26.